﻿var vue = new Vue({
    el: "#app",
    data() {
        return {
            username: "",
            password: ""
        }
    },
    methods: {
        async onSubmit() {
            var res = await axios({
                url: '/login',
                method: 'POST',
                data: {
                    userName: this.username,
                    pswd: this.password
                }
            });
            //获取接口返回结果
            var resData = res.data;
            if (resData.status == 0) {
                this.$toast({
                    type: 'success',
                    message: '登录成功'
                });
                window.location.href = this.getQueryString('ReturnUrl');
            } else {
                this.$toast({
                    type: 'fail',
                    message: resData.msg
                });
            }

        },
        getQueryString(name) {
            let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
            let r = window.location.search.substr(1).match(reg);
            if (r != null) {
                return decodeURIComponent(r[2]);
            };
            return null;
        }
    },
    created() {

    }
});